package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.log.service.SysOperLogService;
import com.atguigu.spzx.model.common.Result;
import com.atguigu.spzx.model.dto.sys.SysOperLogDto;
import com.atguigu.spzx.model.entity.sys.SysOperLog;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * title:
 * author: zgl
 * date: 2024/1/1
 * description：
 */
@RestController
@RequestMapping("/admin/system/log")
@Tag(name = "日志管理模块")
public class SysOperLogController {
    @Autowired
    private SysOperLogService sysOperLogService;

    //条件查询日志列表
    @GetMapping("/logList/{pageNum}/{pageSize}")
    @Operation(summary = "查询日志信息接口")
    public Result getLogList(
            @PathVariable Integer pageNum,
            @PathVariable Integer pageSize,
            SysOperLogDto sysOperLogDto) {
        PageInfo<SysOperLog> pageInfo = sysOperLogService.getLogList(pageNum, pageSize, sysOperLogDto);
        return Result.ok(pageInfo);
    }

    //根据id查询信息
    @GetMapping("/getLog/{id}")
    @Operation(summary = "id查询日志接口")
    public Result getLog(@PathVariable Long id) {
        SysOperLog sysOperLog = sysOperLogService.getLog(id);
        return Result.ok(sysOperLog);
    }
}
